package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.ZhcaRotationchartVo;
import com.ruoyi.system.bo.ZhcaRotationchartQueryBo;
import com.ruoyi.system.bo.ZhcaRotationchartAddBo;
import com.ruoyi.system.bo.ZhcaRotationchartEditBo;
import com.ruoyi.system.service.IZhcaRotationchartService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 轮播图设置Controller
 *
 * @author ruoyi
 * @date 2021-08-09
 */
@Validated
@Api(value = "轮播图设置控制器", tags = {"轮播图设置管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/RotationchartControlle")
public class ZhcaRotationchartController extends BaseController {

    private final IZhcaRotationchartService iZhcaRotationchartService;

    /**
     * 查询轮播图设置列表
     */
    @ApiOperation("查询轮播图设置列表")
    //@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:list')")
    @GetMapping("/list")
    public TableDataInfo<ZhcaRotationchartVo> list(@Validated ZhcaRotationchartQueryBo bo) {
        return iZhcaRotationchartService.queryPageList(bo);
    }

    /**
     * 导出轮播图设置列表
     */
    @ApiOperation("导出轮播图设置列表")
	//@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:export')")
    @Log(title = "轮播图设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<ZhcaRotationchartVo> export(@Validated ZhcaRotationchartQueryBo bo) {
        List<ZhcaRotationchartVo> list = iZhcaRotationchartService.queryList(bo);
        ExcelUtil<ZhcaRotationchartVo> util = new ExcelUtil<ZhcaRotationchartVo>(ZhcaRotationchartVo.class);
        return util.exportExcel(list, "轮播图设置");
    }

    /**
     * 获取轮播图设置详细信息
     */
    @ApiOperation("获取轮播图设置详细信息")
	//@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:query')")
    @GetMapping("/{id}")
    public AjaxResult<ZhcaRotationchartVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("id") Long id) {
        return AjaxResult.success(iZhcaRotationchartService.queryById(id));
    }

    /**
     * 新增轮播图设置
     */
    @ApiOperation("新增轮播图设置")
	//@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:add')")
    @Log(title = "轮播图设置", businessType = BusinessType.INSERT)
    @RepeatSubmit
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody ZhcaRotationchartAddBo bo) {
        return toAjax(iZhcaRotationchartService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改轮播图设置
     */
    @ApiOperation("修改轮播图设置")
	//@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:edit')")
    @Log(title = "轮播图设置", businessType = BusinessType.UPDATE)
    @RepeatSubmit
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody ZhcaRotationchartEditBo bo) {
        return toAjax(iZhcaRotationchartService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除轮播图设置
     */
    @ApiOperation("删除轮播图设置")
	//@PreAuthorize("@ss.hasPermi('system:RotationchartControlle:remove')")
    @Log(title = "轮播图设置" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] ids) {
        return toAjax(iZhcaRotationchartService.deleteWithValidByIds(Arrays.asList(ids), true) ? 1 : 0);
    }
}
